package com.projet.blocs.obstacles;

import android.content.res.Resources;
import com.projet.blocs.Bloc;
import com.projet.labyrinth.Bille;
import com.projet.labyrinth.LabyrinthEngine;

public class Trou extends Bloc {

	private double _centreX;
	private double _centreY;
	public static int collisionSoundId;
	
	public Trou(int tailleBloc, int x, int y, Resources res, int idSprite) {
		super(tailleBloc, x, y, res, idSprite);
		_centreX = left + (right - left) / 2;
		_centreY = top + (bottom - top) / 2;
	}

	@Override
	public void CollisionInterieure(Bille bille) {
		double distance = Math.hypot(bille.GetXCentre() - _centreX, bille.GetYCentre() - _centreY);
		
		if(distance < _tailleBloc / 2) {
			PlaySound();
			bille.Reset();	
		}
	}
	
	protected void PlaySound() {
		LabyrinthEngine.soundPool.play(collisionSoundId, 1, 1, 0, 0, 1);
	}
}
